home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / wctunits.zip / STRINGS.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-20  |  990b  |  58 lines

  1. unit strings;
  2.  
  3. { Written by William C. Thompson }
  4.  
  5. { This unit was written to do a few basic things with strings }
  6.  
  7. interface
  8.  
  9. function allup(s:string):string;
  10. function lowcase(c:char):char;
  11. function alllow(s:string):string;
  12. function rep(s:string; n:integer):string;
  13. procedure reverse(var s:string);
  14.  
  15. implementation
  16.  
  17. function allup(s:string):string;
  18. var i:byte;
  19. begin
  20.   for i:=1 to length(s) do s[i]:=upcase(s[i]);
  21.   allup:=s
  22. end;
  23.  
  24. function lowcase(c:char):char;
  25. begin
  26.   if c in ['A'..'Z'] then c:=chr(ord(c)+32);
  27.   lowcase:=c
  28. end;
  29.  
  30. function alllow(s:string):string;
  31. var i:byte;
  32. begin
  33.   for i:=1 to length(s) do s[i]:=lowcase(s[i]);
  34.   alllow:=s
  35. end;
  36.  
  37. function rep(s:string; n:integer):string;
  38. var
  39.   t: string;
  40.   i: integer;
  41. begin
  42.   t:='';
  43.   for i:=1 to n do t:=t+s;
  44.   rep:=t
  45. end;
  46.  
  47. procedure reverse(var s:string);
  48. var
  49.   t: string;
  50.   l,i: integer;
  51. begin
  52.   l:=length(s);
  53.   t:=s;
  54.   for i:=l downto 1 do t[l+1-i]:=s[i];
  55.   s:=t
  56. end;
  57.  
  58. end.